import Vue from 'vue';
import alertMain from '#/Plugins/alertMain';

const AlertBox = Vue.extend(alertMain);
let instance;

const Alert = function (options = {}) {
	if (Vue.prototype.$isServer) return;
	if (typeof options === 'string') {
		options = {
			message: options
		}
	}
	instance = new AlertBox({
		data: options
	});
	instance.vm = instance.$mount();
	document.body.appendChild(instance.vm.$el);
	instance.vm.visible = true;
	return instance.vm;
};


export default {
	Alert,
	install(vue) {
		vue.prototype.$alert = Alert;
	}
}
